// 向table中动态添加数据

// 1.产生数据
const dataObj = {
	userNo: [1,2,3,4,5,6,7,8],
	userName: ['aa','bb','cc','dd','ee','ff','gg','hh'],
	userScore: [11,12,13,14,15,16,1,12],
	userTaller: [110,120,130,140,150,160,170,180],
	userWeight: [50,55,60,65,70,75,80,85],
	userHobby: ['aBall','bBall','cBall','dBall','eBall','fBall','gBall','hBall'],
	userSex: ['man','woman','man','woman','man','woman','man','woman'],
	userSetting: [11,12,13,14,15,16,1,12]
};

// 2.添加数据
const fn1 = function(){
	const dataTableRow = document.getElementsByTagName('tr')[1];
	const nodeTable = document.getElementsByTagName('table')[0];
	const nodeTbody = nodeTable.getElementsByTagName('tbody')[0];
	const tRow = document.createElement('tr');
    nodeTbody.appendChild(tRow);
    let str1 = '';
    for (let i = 0; i < dataObj.userNo.length; i++) {
        if (i === 0) {
            str1 = '<td>' + dataObj.userNo[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userName.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userName[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userScore.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userScore[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userTaller.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userTaller[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userWeight.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userWeight[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userHobby.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userHobby[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userSex.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userSex[0] + '</td>';
        }
    }
    for (let i = 0; i < dataObj.userSetting.length; i++) {
        if (i === 0) {
            str1 = str1 + '<td>' + dataObj.userSetting[0] + '</td>';
        }
    }
    tRow.innerHTML = str1;
};
fn1();

